﻿<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Demo</title>
    <script src="~/js/layui/layui.js"></script>
    <link href="~/js/layui/css/layui.css" rel="stylesheet" />
    <link href="~/X-admin/css/xadmin.css" rel="stylesheet" />
    <script src="~/X-admin/js/jquery.min.js"></script>
    <script src="~/X-admin/js/xadmin.js"></script>
    <script src="~/js/framework/sysframework.js"></script>
    <script src="~/js/framework/commonjs.js"></script>
</head>
<body>
    <div class="layui-card" style="padding-top:2%;padding-bottom:1%">
        <form id="pForm" class="layui-form layui-col-space5" lay-filter="pform-filter">
            <div class="layui-form-item" style="margin-left:1%">
                <div class="layui-input-group" style="float:left;">
                    <div class="layui-input-prefix">
                       计划编码
                    </div>
                    <input type="text" id="plCode" name="plCode" class="layui-input" readonly />
                </div>
                <div class="layui-input-group" style="float:left;margin-left:4%">
                    <div class="layui-input-prefix">
                       销售订单
                    </div>
                    <input type="text" id="erpOrder" name="erpOrder" class="layui-input" readonly />

                </div>
                <div class="layui-input-group" style="float:left;margin-left:4%">
                    <div class="layui-input-prefix">
                      完工日期
                    </div>
                    <input type="text" id="finishDate" name="finishDate" class="layui-input" readonly />

                </div>
            </div>
            <div class="layui-form-item" style="margin-left:1%">
                <div class="layui-input-group" style="float:left;">
                    <div class="layui-input-prefix">
                        成品名称
                    </div>
                    <input type="text" id="proName" name="proName" class="layui-input" readonly />

                </div>
                <div class="layui-input-group" style="float:left;margin-left:4%">
                    <div class="layui-input-prefix">
                        成品规格
                    </div>
                    <input type="text" id="spec" name="spec" class="layui-input" readonly />
                </div>
                <div class="layui-input-group" style="float:left;margin-left:4%">
                    <div class="layui-input-prefix">
                        计划数量
                    </div>
                    <input type="text" id="number" name="number" class="layui-input" readonly />

                </div>
            </div>
            <div class="layui-form-item" style="margin-left:1%">
                <div class="layui-input-group" style="float:left;">
                    <div class="layui-input-prefix">
                      Bom编码
                    </div>
                    <input type="text" id="bomCode" name="bomCode" class="layui-input" readonly />

                </div>
                <div class="layui-input-group" style="float:left;margin-left:4%">
                    <div class="layui-input-prefix">
                        客户名称
                    </div>
                    <input type="text" id="cuName" name="cuName" class="layui-input" style="width:265%" readonly />
                </div>
            </div>
            <div class="layui-form-item" style="margin-left:1%">
                <div class="layui-input-group" style="float:left;">
                    <div class="layui-input-prefix">
                     预期提醒
                    </div>
                    <input type="text" id="remind" name="remind" class="layui-input" readonly />

                </div>
                <div class="layui-input-group" style="float:left;margin-left:4%">
                    <div class="layui-input-prefix">
                     备 注
                    </div>
                    <input type="text" id="memo" name="memo" class="layui-input" style="width:267%" readonly />
                </div>


            </div>
        </form>
   
    </div>
    <div class="layui-tab" lay-filter="test-handle" style="background-color:#fff;">
        <div class="layui-tab layui-tab-brief">
            <ul class="layui-tab-title">
                <li class="layui-this" >工序生产</li>
                <li>原/辅料占用</li>
                <li>生产检验</li>
                <li>计划废料</li>
            </ul>
            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show" id="gx-layui-table-main">
                  <table class="layui-hide" id="list" lay-filter="list"></table>
                </div>
                <div class="layui-tab-item" id="zy-layui-table-main">
                    <table class="layui-hide" id="zylist" lay-filter="zylist"></table>
                </div>
                <div class="layui-tab-item" id="zj-layui-table-main">
                    <table class="layui-hide" id="zjlist" lay-filter="zjlist"></table>
                </div>
                <div class="layui-tab-item">
                    <table class="layui-hide" id="fllist" lay-filter="fllist"></table>
                </div>
            </div>
        </div>

    </div>



</body>
</html>
<script>
    var plCode = "", isRead = "0";
    $(function () {
        plCode = getUrlVariable("plCode");
        $("input[ name='plCode']").val(plCode);
        //loadData();
        loadPlan();
        loadGxData();
        ZhYList();
        // getTableCloums("chRv");
        zhJRecord();
        loadImageList();
    })
    var gxUrl = "../Plan/getDataList?dataType=glgv&condition=";
    function loadGxData() {
        layui.use('table', function () {
            var table = layui.table;
            table.render({
                elem: '#list'
                , cols: [[ //标题栏
                      { field: 'gxOrder', title: '工序序号', width: 90 }
                    , { field: 'gxName', title: '生产工序', width: 150 }
                    , { field: 'startTime', title: '开工时间', width: 180 }
                    , { field: 'finishTime', title: '完成时间', width: 180 }
                    , { field: 'num', title: '生产件数', width: 120 }
                    , { field: 'total', title: '数量合计', width: 120 }
                  

                ]], done: function (res, curr, count) {
                    $.each(res['data'], function (i, j) {
                        if (j['isFinish'] == "1") {
                            TableRowColor('gx-layui-table-main', i, '#C3FDB8');
                        }
                       
                    });

                }
                , url: gxUrl + plCode
                , skin: 'row' //表格风格
                , even: true
                , page: false //是否显示分页
                , limits: [15, 20, 30]
                , limit: 15 //每页默认显示的数量
            });
         

        });
    }
    /**
     * 原辅料占用信息
     * **/
    function ZhYList() {
        layui.use('table', function () {
            var table = layui.table;
            var cols = table.render({
                elem: '#zylist'
                , url: "../Plan/getDataList?dataType=pzyl&condition=" + plCode
                , skin: 'row' //表格风格
                , even: true
                , page: true
                , limits: [15, 20, 30]
                , limit: 15 //每页默认显示的数量
                , cols: [[
                    { field: 'barCode', align: 'center', title: '条码编码', width: 130 }
                    , { field: 'proCode', align: 'center', title: '存货编码', width: 120 }
                    , { field: 'proName', align: 'center', title: '存货名称', width: 180 }
                    , { field: 'spec', align: 'center', title: '规格', width: 180 }
                    , { field: 'number', align: 'center', title: '占用数量', width: 90 }
                    , { field: 'userName', align: 'center', title: '占用人员', width: 120 }
                    , { field: 'houseName', align: 'center', title: '仓库', width: 120 }
                    , { field: 'createtime', align: 'center', title: '时间', width: 170 }
                ]], done: function (data) {
                    $.each(data['data'], function (i, j) {
                        if (j['barStatus'] !== "need-in") {
                            TableRowColor('layui-table-main', i, '#F9FFB2');
                        }
                    });
                }
            });


            //监听工具条
            table.on('tool(zylist)', function (obj) {
                var data = obj.data;
                if (obj.event == 'del') {
                    layer.confirm('确定要取消占用？', function (index) {

                        $.ajax({
                            url: "../Plan/DelPlanZhanYong",
                            data: { "dataId": data.id },
                            type: "post",
                            success: function (data) {
                                if (data.result) {
                                    obj.del();
                                    loadBOM();
                                } else {
                                    layer.msg(data.message);
                                }
                            }
                        });

                        layer.close(index);
                    });
                }
            });


        });
    }
    /**
     * 质检记录
     * **/
    function zhJRecord() {
        var obj = new Object();
        obj.planCode = plCode;
        layui.use('table', function () {
            var table = layui.table;
            table.render({
                elem: '#zjlist'
                , cols: [[
                    { field: 'crCode', title: '检验编码', width: 140 }
                    , { field: 'checkBar', title: '条码编码', width: 130 }
                    , { field: 'proCode', title: '存货编码', width: 100 }
                    , { field: 'proName', title: '存货名称', width: 130 }
                    , { field: 'spec', title: '规格', width: 110 }
                    , { field: 'planCode', title: '关联计划', width: 100 }
                    , { field: 'hDate', title: '质检日期', width: 100 }
                    , { field: 'checkUserName', title: '检验人员', width: 120 }
                    , { field: 'resultName', title: '检验结果', width: 100 }
                ]]
                , done: function (res, curr, count) {
                    currPage = curr;
                    TablePowerHide();

                }
                , url: "../Quality/getDataList?dataType=chRl&condition=" + JSON.stringify(obj)
                , skin: 'row' //表格风格
                , even: true
                , page: true //是否显示分页
                , limits: [15, 20, 30]
                , limit: 15 //每页默认显示的数量
                , id: "list"
            });
        });


    }

    /**
     * 获取计划附件
     * **/
    function loadImageList() {
        layui.use('table', function () {
            var table = layui.table;
            table.render({
                elem: '#fllist'
                , height: 'full-200'   //固定高度-即固定表头固定第一行首行
                , cols: [[ //标题栏
                    { field: 'reBarCode', title: '关联条码', width: 120 }
                    , { field: 'proName', title: '关联存货', width: 140 }
                    , { field: 'flTypeName', title: '废料类型', width: 120 }
                    , { field: 'number', title: '废料数量(kg)', width: 110 }
                    , { field: 'createtime', title: '录入时间', width: 180 }
                    , { field: 'userName', title: '录入人员', width: 120 }

                ]], done: function (res, curr, count) {
                }
                , url: "../Plan/getDataList?dataType=pWaste&condition=" + plCode
                , skin: 'row' //表格风格
                , even: true
                , page: true //是否显示分页
                , limits: [20, 30, 50]
                , limit: 50 //每页默认显示的数量
            });

        });
    }
    layui.use('element', function () {
        var element = layui.element;

        //监听Tab切换，以改变地址hash值
        element.on('tab(test1)', function () {
           
            //location.hash = 'test1=' + this.getAttribute('lay-id');
        });
    });

    function loadPlan() {
        $.ajax({
            url: "../Plan/getPlanInfoByCode",
            data: { plCode: plCode },
            type: "post",
            success: function (rsl) {
                if (rsl.result) {
                    layui.use('form', function () {
                        var form = layui.form;
                        form.val('pform-filter', rsl.data[0]);
                        form.render();
                    });

                } else {
                    layer.msg(rsl.message);
                }
            }
        });
    }

    //获取计划附件
    function loadData() {
        layui.use('table', function () {
            var table = layui.table;
            table.render({
                elem: '#list'
                , height: 'full-200'   //固定高度-即固定表头固定第一行首行
                , cols: [[ //标题栏
                    { field: 'fileName', title: '文件名称', width: 350 }
                    , { field: 'filePath', title: '图片', width: 130, templet: function (d) { return '<div onclick="show_img(this)" ><img src="' + d.filePath + '" ' + 'alt="" width="50px" height="50px"></a></div>'; } }

                ]], done: function (res, curr, count) {
                }
                , url: "../Plan/getDataList?dataType=file&condition=" + plCode
                , skin: 'row' //表格风格
                , even: true
                , page: false //是否显示分页
                , limits: [20, 30, 50]
                , limit: 50 //每页默认显示的数量
            });

        });
    }

    //放大图片
    function show_img(t) {
        var t = $(t).find("img");
        //页面层
        layer.open({
            type: 1,
            title: '图片详情',
            skin: 'layui-layer-rim', //加上边框
            area: ['90%', '90%'], //宽高 t.width() t.height()
            shadeClose: true, //开启遮罩关闭
            end: function (index, layero) {
                return false;
            },
            content: '<div style="text-align:center"><img src="' + $(t).attr('src') + '" /></div>'
        });
    }


</script>